package cz.najman.emdroid.helper;

import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.util.Log;
import cz.najman.emdroid.connection.ConnectionMethod;
import cz.najman.emdroid.mappings.EventInstitutionManager;
import cz.najman.emdroid.mappings.Institution;
import cz.najman.emdroid.service.ForwardingResultReceiver;
import cz.najman.emdroid.service.UpdaterService;

public class EventInstitutionManagerHelper extends AbstractHelper{

	private static final String TAG = "EventInstitutionManagerHelper";
	
	public EventInstitutionManagerHelper(Context context, ForwardingResultReceiver receiver) {
		super(context, receiver);		
	}

	/* ***************************************************************
	 * 					REMOTE HELPER METHODS 						 *
	 * ***************************************************************/
	
	public void retrieveInstitutionsEventInstitutionManagers(int institutionId){
		Log.d(TAG, "> retrievingEventInstitutionManagersForInstitution");
		Intent intent = getIntentWithExtra(
				EventInstitutionManager.CONTENT_URI_EVNT_INST_MNG_FOR_INSTITUTION,
				ConnectionMethod.METHOD_GET,
				new String[] {Institution.URI_TEMPLATE_STRING},
				new String[] {"" + institutionId},
				null
			);        
        mContext.startService(intent);
	}
	
	@Override
	protected Intent getIntentWithExtra(Uri uri, int method, String[] parameterTypes, String[] parameterValues, ContentValues values) {
		Intent intent = new Intent(mContext, UpdaterService.class);
		intent.putExtra(UpdaterService.RESULT_RECEIVER,	mResultReceiver);
		intent.putExtra(UpdaterService.OBJECT, EventInstitutionManager.class);
		intent.putExtra(UpdaterService.URI, uri);
		intent.putExtra(UpdaterService.METHOD, method);
		if (parameterTypes != null) {
			intent.putExtra(UpdaterService.PARAMETER_TYPES, parameterTypes);
			intent.putExtra(UpdaterService.PARAMETER_VALUES, parameterValues);
		}
		if (values != null) {
			intent.putExtra(UpdaterService.CONTENT_VALUES, values);
		}

		return intent;
	}

	
	/* ***************************************************************
	 * 					DATABASE HELPER METHODS 					 *
	 * ***************************************************************/
}
